package cc.comac.mom.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cc.comac.mom.api.EquipDevAreaDefService;
import cc.comac.mom.bean.EquipDevAreaDef;
import cc.comac.mom.bean.EquipDevAreaDefBean;
import cc.comac.mom.util.ResultBean;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(value ="/EquipDevAreaDef")
public class EquipDevAreaDefController {
	
	@Autowired
	private EquipDevAreaDefService equipDevAreaDefService;
	@RequestMapping(value = "/save",method = RequestMethod.POST)
	public Object save(@RequestBody EquipDevAreaDef obj) {
		
		return equipDevAreaDefService.save(obj);
		
	}
	
	@RequestMapping(value = "/update",method = RequestMethod.POST)
	public Object update(@RequestBody EquipDevAreaDef obj) {
		
		return equipDevAreaDefService.update(obj);
		
	}
	
	@RequestMapping(value = "/delete",method = RequestMethod.POST)
	public Object delete(@RequestBody EquipDevAreaDef obj) {
		
		return equipDevAreaDefService.delete(obj);
		
	}
	
	@RequestMapping(value = "/getById",method = RequestMethod.POST)
	public EquipDevAreaDef getById(@RequestBody EquipDevAreaDef obj) {
		return equipDevAreaDefService.getById(obj);
		
	}
	
	@RequestMapping(value = "/getAreaNameByEquipTypeId/{id}")
	public ResultBean getAreaNameByEquipTypeId(@PathVariable long id) {
		ResultBean resultBean = new ResultBean(true);
		List<EquipDevAreaDef> listEquipDevAreaDef = equipDevAreaDefService.getAreaNameByEquipTypeId(id);
		resultBean.setObject(listEquipDevAreaDef);
		return resultBean;
		
	}
	@ApiOperation("通过设备主数据id获取部位信息")
	@RequestMapping("/getAreaNameByDevId/{id}")
	public ResultBean getAreaNameByDevId(@PathVariable long id) {
		return equipDevAreaDefService.getAreaNameByDevId(id);		
	}
	
	@RequestMapping(value = "/selectByCondition",method = RequestMethod.POST)
	public EquipDevAreaDefBean selectByCondition(@RequestBody EquipDevAreaDef obj) {
		return equipDevAreaDefService.selectByCondition(obj);
		
	}
}
